#pragma once
#ifndef __LEXER_H__
#define __LEXER_H__

#include "NezhaFoundation.h"

class cToken;

class cLexer
{
public:
	cLexer();
	cLexer( Nezha::stream::IReadFile* pfile );
	cLexer( const char* pbuffer, unsigned int size );
	virtual ~cLexer();

	virtual void SetSource(Nezha::stream::IReadFile* pfile );
	virtual void SetSource( const char* pbuffer, unsigned int size );

	virtual int GetNextToken( cToken* ptoken );

	virtual int GetNextString( cToken* ptoken );
	
	virtual int GetNextStringForKeyword(cToken* ptoken,const std::string& keyword);

	virtual int GetTokenType( const std::string& keyword );

	virtual bool IsEnd();

protected:

	char GetNextChar();

	void UngetNextChar();

	void BindKeyword( const std::string& keyword, int tokenType );

protected:

	const char* mpBuffer;
	long mBufferLen;

	unsigned int mPos;

	int mLine;

	typedef std::map<std::string, int> cKeywordMap;
	cKeywordMap mKeywordMap;
};

#endif // __LEXER_H__